const router = require('koa-router')()
router.prefix('/question')
const {
    find,
    findById,
    create,
    update,
    deleteQuestion,
    checkQuestioner,
    checkQuestionExist
} = require("../controller/questions")
const auth = require("../utils/auth")

// 查询话题列表
router.get("/", find)
// 创建一个话题
router.post("/create", auth, create)
// 根据ID查询特定话题
router.get("/:id", checkQuestionExist, findById)
// 更新一个话题
router.patch("/:id", auth, checkQuestionExist, checkQuestioner, update)
// 删除一个问题
router.delete("/:id", auth, checkQuestionExist, checkQuestioner, deleteQuestion)


module.exports = router
